package com.nononsenseapps.feeder.ui.base

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import com.nononsenseapps.feeder.db.room.AppDatabase

/**
 * A ViewModel which is also Coroutine aware.
 *
 * All coroutines started in this view model are linked to the lifecycle. If the view model
 * is destroyed, then all coroutines are cancelled. Likewise, if any of the coroutines encounter
 * an exception, that cancels the other coroutines
 */
open class CoroutineScopedViewModel(application: Application) : AndroidViewModel(application) {
    protected val feedItemDao by lazy { AppDatabase.getInstance(application).feedItemDao()}
    protected val feedDao by lazy { AppDatabase.getInstance(application).feedDao()}

}